import 'package:flutter/material.dart';
import 'CommendPage.dart';
import 'AllBuildPage.dart';
import 'Other.dart';

class BottomNavigationWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => BottomNavigationWidgetState();
}

class BottomNavigationWidgetState extends State<BottomNavigationWidget> {
  final _bottomNavigationColor = Colors.blue;
  int _currentIndex = 0;
  List<Widget> list = List();

  @override
  void initState() {
    list
      ..add(CommendPage())
      ..add(AllBuildPage())
      ..add(OtherPage());

      // ..add(WelcomeScreen())
      // ..add(OtherScreen());
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: list[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
              icon: Icon(
                Icons.home,
                color: _bottomNavigationColor,
              ),
              title: Text(
                '推荐',
                style: TextStyle(color: _bottomNavigationColor),
              )),
          BottomNavigationBarItem(
              icon: Icon(
                Icons.email,
                color: _bottomNavigationColor,
              ),
              title: Text(
                '全部',
                style: TextStyle(color: _bottomNavigationColor),
              )),
          BottomNavigationBarItem(
              icon: Icon(
                Icons.pages,
                color: _bottomNavigationColor,
              ),
              title: Text(
                '其他',
                style: TextStyle(color: _bottomNavigationColor),
              )),
        ],
        currentIndex: _currentIndex,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
        type: BottomNavigationBarType.shifting,
      ),
    );
  }
}

//import 'package:flutter/material.dart';
//import 'CommendPage.dart';
//import 'AllBuildPage.dart';
//import 'Other.dart';
//
//
//class KYVMNavigate extends StatefulWidget {
//  @override
//  _NavigateState createState() => _NavigateState();
//}
//
//class _NavigateState extends State<KYVMNavigate>
//    with SingleTickerProviderStateMixin {
//
//  final _bottomNavigationColor = Colors.grey;
//  final _bottomNavigationSelectColor = Colors.blue;
//  int _currentIndex = 0;
//  var _controller = PageController(
//    initialPage: 0,
//  );
//
//  @override
//  void dispose() {
//    super.dispose();
//    _controller.dispose();
//  }
//
//  @override
//  Widget build(BuildContext context) {
//    return Scaffold(
//      body: PageView(
//        controller: _controller,
//        children: <Widget>[
//          CommendPage(),
//          AllBuildPage(),
//          OtherPage(),
//        ],
//        physics: NeverScrollableScrollPhysics(),
//      ),
//      bottomNavigationBar: BottomNavigationBar(
//        currentIndex: _currentIndex,
//        onTap: (index) {
//          _controller.jumpToPage(index);
//          setState(() {
//            _currentIndex = index;
//          });
//        },
//        type: BottomNavigationBarType.fixed,
//        items: [
//          BottomNavigationBarItem(
//            activeIcon: Icon(
//              Icons.home,
//              color: _bottomNavigationSelectColor,
//            ),
//            icon: Icon(
//              Icons.home,
//              color: _bottomNavigationColor,
//            ),
//            title: Text(
//              '首页',
//              style: TextStyle(color:_bottomNavigationSelectColor),
//            ),
//          ),
//          BottomNavigationBarItem(
//            activeIcon: Icon(
//              Icons.message,
//              color: _bottomNavigationSelectColor,
//            ),
//            icon: Icon(
//              Icons.message,
//              color: _bottomNavigationColor,
//            ),
//            title: Text(
//              '消息',
//              style: TextStyle(color:_bottomNavigationSelectColor),
//            ),
//          ),
//          BottomNavigationBarItem(
//            activeIcon: Icon(
//              Icons.person,
//              color: _bottomNavigationSelectColor,
//            ),
//            icon: Icon(
//              Icons.person,
//              color: _bottomNavigationColor,
//            ),
//            title: Text(
//              '我的',
//              style: TextStyle(color:_bottomNavigationSelectColor),
//            ),
//          ),
//        ],
//      ),
//    );
//  }
//}